import java.util.ArrayList;
import java.util.Date;

public class CLI
{

	public CLI()
	{
	}

	public static void main(String[] args)
	{
		database.openBusDatabase();
		Date date = new Date();

		//    TEST CASE 0

		//example of general case to print TO FILE whole timetables
		int route = TimetableInfo.findRoute("358back");
		Timetables.showTimetable(route, TimetableInfo.timetableKind.weekday);

		//TEST CASE 1 NO BUS CHANGE

		testPassengerChoice("Marple", "Stockport", "Navigation Hotel",
				"Bus Station", date, 580);


        /*RealTime.checkInfo("Marple", "Stockport", "Navigation Hotel",
				"Bus Station", date, 580);*/
        
		//TEST CASE 2 NO BUS CHANGE

		testPassengerChoice("Marple", "Romiley", "Navigation Hotel",
				"Corcoran Drive", date, 670);

		//TEST CASE 3 WITH BUS CHANGE

		//from Romley to Heyfield expected change
		testPassengerChoice("Romiley", "Hayfield", "Corcoran Drive", "Bus Station",
				date, 1110);

		//TEST CASE 4 WITH BUS CHANGE

		//from Heyfield to Romley expected change
		testPassengerChoice("Hayfield", "Romiley", "Bus Station", "Corcoran Drive",
				date, 1115);

	}//main

	public static void testPassengerChoice(String startArea, String endArea,
			String startStop, String endStop, Date date, int time)
	{
		boolean change = false;
		ArrayList<Journey> possChecks4 = PassengerChoice.findJourneyOptions(
				startArea, endArea, startStop, endStop, date);
		if (possChecks4.isEmpty())
		{
			ArrayList<Journey> firstCheck = PassengerChoice.findChangeOptionsFirst(
					startArea, endArea, startStop, endStop, date);
			if (firstCheck.isEmpty())
				Timetables.printNoJourney();
			else
			{
				PassengerChoice first = new PassengerChoice(time, firstCheck);
				Journey firstOptimal = first.getOptimal();
                //firstOptimal.toString();
				ArrayList<Journey> secondCheck = PassengerChoice.findJourneyOptions(
						"Marple", endArea, "Navigation Hotel", endStop, date);
				PassengerChoice second = new PassengerChoice(firstOptimal
						.getArrivalTime(), secondCheck);
				Journey secondOptimal = second.getOptimal();
                System.out.println();
                //secondOptimal.toString();
				if (!secondCheck.isEmpty())
					change = true;
				Timetables.printPassengerChoice(firstOptimal, secondOptimal);
			}
		}
		if (!change)
		{
			if (possChecks4.isEmpty())
                Timetables.printNoJourney();
			else
			{
				PassengerChoice example4 = new PassengerChoice(time, possChecks4);
				Journey optimalJourney4 = example4.getOptimal();
                //optimalJourney4.toString();
				Timetables.printPassengerChoice(optimalJourney4);
			}
		}
	}

}
